var dbConfig = require('../util/dbconfig')

login = (req, res) => {
    var { username, password } = req.query
    var sql = "select username,password from user where username=?&password=?";
    var sqlArr = [username, password];
    var callBack = (err, data) => {
        if (err) {
            res.send({
                code: 400,
                msg: '获取出错！',
                'list': data
            })
        } else {
            res.send({
                code: 200,
                msg: 'success',
                'list': data
            })
        }
    }
    dbConfig.sqlConnect(sql, sqlArr, callBack);
},
getUserInfo = (req, res) => {
    var { username } = req.query
    var sql = "select * from user where username=?";
    var sqlArr = [username];
    var callBack = (err, data) => {
        if (err) {
            res.send({
                code: 400,
                msg: '获取出错！',
                'list': data
            })
        } else {
            res.send({
                code: 200,
                msg: 'success',
                'list': data
            })
        }
    }
    dbConfig.sqlConnect(sql, sqlArr, callBack);
},

    module.exports = {
        login,
        getUserInfo
    } 